package com.geek.netty.demo.nio;

import com.geek.netty.demo.DemoServer;

import java.io.*;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

/**
 * @program netty-server
 * @description: client
 * @author: chanzhugang
 * @create: 2021/08/16 16:00
 */
public class NIOClient {

    public static void main(String[] args) {

        NIOServer nioServer = new NIOServer();
        nioServer.start();

        try (Socket client = new Socket(InetAddress.getLocalHost(), 8081)) {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(client.getInputStream()));
            bufferedReader.lines().forEach(s -> System.out.println(s));
        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}